package com.ruoyi.shop.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.mapper.ShopProductCommentMapper;
import com.ruoyi.shop.domain.ShopProductComment;
import com.ruoyi.shop.service.IShopProductCommentService;
import com.ruoyi.common.core.text.Convert;

/**
 * 商品评论Service业务层处理
 * 
 * @author Alan Zhang
 * @date 2021-09-12
 */
@Service
public class ShopProductCommentServiceImpl implements IShopProductCommentService 
{
    @Autowired
    private ShopProductCommentMapper shopProductCommentMapper;

    /**
     * 查询商品评论
     * 
     * @param id 商品评论主键
     * @return 商品评论
     */
    @Override
    public ShopProductComment selectShopProductCommentById(Long id)
    {
        return shopProductCommentMapper.selectShopProductCommentById(id);
    }

    /**
     * 查询商品评论列表
     * 
     * @param shopProductComment 商品评论
     * @return 商品评论
     */
    @Override
    public List<ShopProductComment> selectShopProductCommentList(ShopProductComment shopProductComment)
    {
        return shopProductCommentMapper.selectShopProductCommentList(shopProductComment);
    }

    /**
     * 新增商品评论
     * 
     * @param shopProductComment 商品评论
     * @return 结果
     */
    @Override
    public int insertShopProductComment(ShopProductComment shopProductComment)
    {
        return shopProductCommentMapper.insertShopProductComment(shopProductComment);
    }

    /**
     * 修改商品评论
     * 
     * @param shopProductComment 商品评论
     * @return 结果
     */
    @Override
    public int updateShopProductComment(ShopProductComment shopProductComment)
    {
        return shopProductCommentMapper.updateShopProductComment(shopProductComment);
    }

    /**
     * 批量删除商品评论
     * 
     * @param ids 需要删除的商品评论主键
     * @return 结果
     */
    @Override
    public int deleteShopProductCommentByIds(String ids)
    {
        return shopProductCommentMapper.deleteShopProductCommentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品评论信息
     * 
     * @param id 商品评论主键
     * @return 结果
     */
    @Override
    public int deleteShopProductCommentById(Long id)
    {
        return shopProductCommentMapper.deleteShopProductCommentById(id);
    }

    /**
     * 前两条最新 商品评论
     * @param productId 商品id
     * @return
     */
    @Override
    public List<ShopProductComment> selectTop2ShopProductCommentByProductId(Long productId){
        return shopProductCommentMapper.selectTop2ShopProductCommentByProductId(productId);
    }
}
